<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>get请求参数</h1>
<input type="text" name="name" id="name">
<input type="password" name="pwd" id="pwd">
<input type="button" value="提交" onclick="submitForm()">
<script>
    function form1() {
        //创建Ajax对象
        let xhr = new XMLHttpRequest()
        // 设置url
        url = 'http://httpbin.org/get'
        //拼接请求参数
        args = '?uname=sxt&pwd=123'
        url = url + args
        // 设置请求参数
        xhr.open('GET', url)
        //发送请求
        xhr.send()
        //获取响应数据
        xhr.onload = function () {
            console.log(xhr.responseText)
        }
    }

    function submitForm(){
        let uname = document.getElementById('name').value
        let pwd  = document.getElementById('pwd').value
        //创建Ajax对象
        let xhr = new XMLHttpRequest()
        // 设置url
        url = 'http://httpbin.org/get'
        //拼接请求参数
        args = '?uname='+uname+'&pwd='+pwd
        url = url + args
        // 设置请求参数
        xhr.open('GET', url)
        //发送请求
        xhr.send()
        //获取响应数据
        xhr.onload = function () {
            console.log(xhr.responseText)
        }
    }


</script>
</body>
</html>